package acl.action;



import acl.bussiness.UserBusiness;
import acl.hibernate.po.*;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.json.annotations.*;

public class LoginAction extends ActionSupport {
	private String username;
	private String password;
	private String state;//process result
	
	
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public void setPassword(String password)
	{
		this.password=password;
	}
	public String getPassword()
	{
		return this.password;
	}	
	public String getState()
	{
		return this.state;
	}
	public void setState(String state)
	{
		this.state=state;
	}
	public String execute() throws Exception
	{		
		UserBusiness ubus=new UserBusiness();
		if(ubus.canLogin(this.getUsername(), this.getPassword())==true)
		{
			
			this.state="1";
			return Action.SUCCESS;
			
		}
		else
		{
			this.state="0";
			addActionError(getText("LOGIN_FAILED"));
			return Action.ERROR;
			
		}
		
			
		
	}
}
